﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_Account : System.Web.UI.UserControl
{
    private Logging objLogging = new Logging();
    private string strApplicationName = MethodBase.GetCurrentMethod().DeclaringType.Name;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                FirstName.Text = Profile.FirstName;
                LastName.Text = Profile.LastName;
                DateOfBirth.SelectedDate = Profile.DateOfBirth;
                Hobby.Text = Profile.Hobby;
            }
            TextBox1.Attributes.Add("readonly", "readonly");
        }
        catch (Exception ex)
        {
            objLogging.WriteLine(strApplicationName, ex.Message);
        }
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                Profile.FirstName = FirstName.Text;
                Profile.LastName = LastName.Text;
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                dtfi.ShortDatePattern = "dd-MM-yyyy";
                dtfi.DateSeparator = "-";
                DateTime objDate = Convert.ToDateTime(TextBox1.Text, dtfi);
                Profile.DateOfBirth = objDate;
                DateOfBirth.SelectedDate = Profile.DateOfBirth;
                Profile.Hobby = Hobby.Text;
            }
        }
        catch (Exception ex)
        {
            objLogging.WriteLine(strApplicationName, ex.Message);
        }
    }
}